#!/bin/bash

#make executable with chmod +rx makeDoc

#edit these to be relative to the location from where you want to run this script
DOC_DIR="../doc"

##########

echo making docs...

SRCS="Utility.hs Cyc.hs Theory.hs Main.hs" #ghc -M Main.hs can make this list for us, but we'd have to parse out all the *.hs from the Makefile it makes.
DOC_SRC_DIR="$DOC_DIR/src"

rm -r $DOC_DIR

mkdir $DOC_DIR
mkdir $DOC_SRC_DIR

for file in $SRCS
do
echo hscolouring $file
~/.cabal/bin/HsColour -html -anchor $file > $DOC_SRC_DIR/`dirname $file`/`basename $file .hs`.html
done

echo haddocking...
haddock -ho $DOC_DIR $SRCS \
    --source-module="$DOC_SRC_DIR/%{MODULE/.//}.html" \
    --source-entity="$DOC_SRC_DIR/%{MODULE/.//}.html#%{NAME}"

echo done making docs.